home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 16 / CU Amiga Magazine's Super CD-ROM 16 (1997-10-16)(EMAP Images)(GB)[!][issue 1997-11].iso / CUCD / Utilities / moreHTML / Source / MAIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-11  |  51.2 KB  |  1,755 lines

  1. /*
  2.  *  moreHTML
  3.  *  © Dirk Holtwick, 1997
  4.  *  ---------------------
  5. ///
  6.     I publish this source, but that doesn't mean that it is  free.  It
  7.     still remains copyrighted by me, Dirk Holtwick, and if you want to
  8.     change the source or add some functions, you first have to get  in
  9.     contact with me and get my permission.
  10.  
  11.     I regret that the comments and the stile of  the  source  are  not
  12.     very  clear,  but  I  will try to make it more readable and better
  13.     structured. For the compilation I used SAS/C 6.57.
  14.  
  15.     I need some help reguarding ARexx and Internet Access. Please  get
  16.     in contact with me if you can help me. Thanks.
  17.  
  18. ///                                                Yours Dirk Holtwick
  19.  */
  20.  
  21. #define VERS      "1.6"
  22. #define NAME      "moreHTML"
  23. #define TMPREXX   "T:moreHTML_temp_command.rexx"
  24. #define TMPINFO   "T:moreHTML_temp_info.rexx"
  25.  
  26. // Choose wether you want debuging infos or not:
  27. // #define DEBUG
  28.  
  29. /// DEBUG
  30. #ifdef DEBUG
  31.    extern void KPrintF(...);
  32.    #define DB KPrintF
  33. #else
  34.    #define DB ; / ## /
  35. #endif
  36. ///
  37. /// Includes
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include <stdio.h>
  41.  
  42. #include <rexx/storage.h>
  43. #include <rexx/rxslib.h>
  44.  
  45. #include <exec/memory.h>
  46. #include <prefs/prefhdr.h>
  47. #include <datatypes/pictureclass.h>
  48. #include <workbench/workbench.h>
  49. #include <libraries/locale.h>
  50. #include <libraries/asl.h>
  51. #include <libraries/gadtools.h>
  52. #include <libraries/mui.h>
  53.  
  54. #include <proto/rexxsyslib.h>
  55.  
  56. #include <clib/exec_protos.h>
  57. #include <clib/graphics_protos.h>
  58. #include <clib/intuition_protos.h>
  59. #include <clib/utility_protos.h>
  60. #include <clib/dos_protos.h>
  61. #include <clib/locale_protos.h>
  62. #include <clib/muimaster_protos.h>
  63. #include <clib/icon_protos.h>
  64. #include <clib/alib_protos.h>
  65.  
  66. #include <pragmas/exec_pragmas.h>
  67. #include <pragmas/graphics_pragmas.h>
  68. #include <pragmas/intuition_pragmas.h>
  69. #include <pragmas/utility_pragmas.h>
  70. #include <pragmas/dos_pragmas.h>
  71. #include <pragmas/locale_pragmas.h>
  72. #include <pragmas/muimaster_pragmas.h>
  73. #include <pragmas/icon_pragmas.h>
  74.  
  75. #include <dos.h>
  76.  
  77. #include <mui/htmltext_mcc.h>
  78. #include <mui/imagebutton_mcc.h>
  79. #include <mui/newstring_mcc.h>
  80.  
  81. #include "cb.h"
  82. #include "mylist.h"
  83. #include "mystring.h"
  84. ///
  85. /// Compiler Stuff
  86. #ifdef _DCC
  87. #define REG(x) __ ## x
  88. #define ASM
  89. #define SAVEDS __geta4
  90. #else
  91. #define REG(x) register __ ## x
  92. #define ASM    __asm
  93. #define SAVEDS __saveds
  94. #endif
  95. ///
  96. /// Definitions
  97. #define MUIM_MainWindow_Finish        0x90a41070
  98. #define MUIM_MainWindow_About         0x90a41071
  99. #define MUIM_MainWindow_Open          0x90a41072
  100. #define MUIM_MainWindow_Iconify       0x90a41073
  101. #define MUIM_MainWindow_Save          0x90a41074
  102. #define MUIM_MainWindow_AddURL        0x90a41075
  103. #define MUIM_MainWindow_ShowURL       0x90a41076
  104. #define MUIM_MainWindow_ReloadURL     0x90a41077
  105. #define MUIM_MainWindow_Config        0x90a41078
  106. #define MUIM_MainWindow_Action        0x90a41079
  107. #define MUIM_MainWindow_Find          0x90a4107a
  108. #define MUIM_MainWindow_Rexx          0x90a4107b
  109.  
  110. #define REQ(text,but)                 MUI_Request(app,obj,0,NULL,but,(char *)text,0)
  111. ///
  112. /// Global Vars
  113. char  openurlstr[80];
  114.  
  115. LONG __stack = 2*8192;
  116.  
  117. struct Library *MUIMasterBase;
  118. struct Library *GfxBase      ;
  119. struct Library *IntuitionBase;
  120. struct Library *LocaleBase   ;
  121. struct Library *AslBase      ;
  122. struct Library *UtilityBase  ;
  123. struct Library *DataTypesBase;
  124.  
  125. Object *win;
  126.  
  127. extern struct Library *DOSBase;
  128.  
  129. struct MUI_CustomClass *CL_MainWindow  ;
  130. ///
  131. /// Menu
  132. #define RB CHECKIT
  133. #define TG CHECKIT|MENUTOGGLE
  134.  
  135. enum
  136. {
  137.    MEN_OPEN=1,
  138.    MEN_SAVE,
  139.    MEN_ABOUT,
  140.    MEN_AMUI,
  141.    MEN_PRINT,
  142.    MEN_PRSRC,
  143.    MEN_EDIT,
  144.    MEN_VIEW,
  145.    MEN_HIDE,
  146.    MEN_QUIT,
  147.    MEN_CPBLOCK,
  148.    MEN_CPTEXT,
  149.    MEN_PATEXT,
  150.    MEN_BACK,
  151.    MEN_FORWARD,
  152.    MEN_RELOAD,
  153.    MEN_CONF,
  154.    MEN_MUI,
  155.    MEN_FIND,
  156.    MEN_NEXT,
  157. };
  158.  
  159. struct NewMenu MainMenu[] =
  160. {
  161.    { NM_TITLE, (STRPTR)"Project"                 , 0 ,0,0,(APTR)0             },
  162.    { NM_ITEM , (STRPTR)"Open"                    ,"O",0,0,(APTR)MEN_OPEN      },
  163.    { NM_ITEM , (STRPTR)"Save as"                 ,"S",0,0,(APTR)MEN_SAVE      },
  164.    { NM_ITEM , (STRPTR)NM_BARLABEL               , 0 ,0,0,(APTR)0             },
  165.    { NM_ITEM , (STRPTR)"Print"                   ,"P",0,0,(APTR)MEN_PRINT     },
  166.    { NM_ITEM , (STRPTR)NM_BARLABEL               , 0 ,0,0,(APTR)0             },
  167.    { NM_ITEM , (STRPTR)"About"                   ,"?",0,0,(APTR)MEN_ABOUT     },
  168.    { NM_ITEM , (STRPTR)"About MUI"               , 0 ,0,0,(APTR)MEN_AMUI      },
  169.    { NM_ITEM , (STRPTR)NM_BARLABEL               , 0 ,0,0,(APTR)0             },
  170.    { NM_ITEM , (STRPTR)"Hide"                    ,"H",0,0,(APTR)MEN_HIDE      },
  171.    { NM_ITEM , (STRPTR)"Quit"                    ,"Q",0,0,(APTR)MEN_QUIT      },
  172.  
  173.    { NM_TITLE, (STRPTR)"Edit"                    , 0 ,0,0,(APTR)0             },
  174.    { NM_ITEM , (STRPTR)"Find"                    ,"F",0,0,(APTR)MEN_FIND      },
  175.    { NM_ITEM , (STRPTR)"Find next"               ,"N",0,0,(APTR)MEN_NEXT      },
  176.    { NM_ITEM , (STRPTR)NM_BARLABEL               , 0 ,0,0,(APTR)0             },
  177.    { NM_ITEM , (STRPTR)"Copy block"              ,"C",0,0,(APTR)MEN_CPBLOCK   },
  178.  
  179.    { NM_TITLE, (STRPTR)"Navigation"              , 0 ,0,0,(APTR)0             },
  180.    { NM_ITEM , (STRPTR)"Back"                    ,"B",0,0,(APTR)MEN_BACK      },
  181.    { NM_ITEM , (STRPTR)"Forward"                 ,"F",0,0,(APTR)MEN_FORWARD   },
  182.    { NM_ITEM , (STRPTR)NM_BARLABEL               , 0 ,0,0,(APTR)0             },
  183.    { NM_ITEM , (STRPTR)"Reload"                  ,"R",0,0,(APTR)MEN_RELOAD    },
  184.  
  185.    { NM_TITLE, (STRPTR)"Source"                  , 0 ,0,0,(APTR)0             },
  186.    { NM_ITEM , (STRPTR)"View"                    ,"V",0,0,(APTR)MEN_VIEW      },
  187.    { NM_ITEM , (STRPTR)"Edit"                    ,"E",0,0,(APTR)MEN_EDIT      },
  188.    { NM_ITEM , (STRPTR)"Copy"                    , 0 ,0,0,(APTR)MEN_CPTEXT    },
  189.    { NM_ITEM , (STRPTR)"Print"                   , 0 ,0,0,(APTR)MEN_PRSRC     },
  190.  
  191.    { NM_TITLE, (STRPTR)"Settings"                , 0 ,0,0,(APTR)0             },
  192.    { NM_ITEM , (STRPTR)"moreHTML"                , 0 ,0,0,(APTR)MEN_CONF      },
  193.    { NM_ITEM , (STRPTR)"MUI"                     , 0 ,0,0,(APTR)MEN_MUI       },
  194.  
  195.    { NM_END,NULL,0,0,0,(APTR)0 },
  196. };
  197. ///
  198. /// Misc Help Functions
  199. LONG xget(Object *obj,ULONG attribute)
  200. {
  201.    LONG x;
  202.    get(obj,attribute,&x);
  203.    return(x);
  204. }
  205.  
  206. ULONG __stdargs DoSuperNew(struct IClass *cl,Object *obj,ULONG tag1,...)
  207. {
  208.    return(DoSuperMethod(cl,obj,OM_NEW,&tag1,NULL));
  209. }
  210. ///
  211. /// Clipboard
  212. int WriteClip(char *string)
  213. {
  214.    struct IOClipReq *ior;
  215.  
  216.    if (string == NULL)
  217.    {
  218.       puts("No string argument given");
  219.       return(0);
  220.    }
  221.    if (ior = CBOpen(0L))
  222.    {
  223.       if (!(CBWriteFTXT(ior,string)))
  224.         printf("Error writing to clipboard: io_Error = %ld\n",ior->io_Error);
  225.       CBClose(ior);
  226.    }
  227.    else
  228.       puts("Error opening clipboard.device");
  229.    return(0);
  230. }
  231. ///
  232.  
  233. // Structures
  234.  
  235. /// struct Config_Data
  236. struct Config_Data
  237. {
  238.    char  viewsource[80];
  239.    char  printtext[80];
  240.    char  editsource[80];
  241.    char  openurl[80];
  242. };
  243. ///
  244. /// struct Tool_Data
  245. struct Tool_Data
  246. {
  247.    struct   Tool_Data
  248.             *next;
  249.    char     *command;
  250.    char     *help;
  251.    char     *picname;
  252.    struct   MUIS_ImageButton_Image
  253.             image;
  254. };
  255. ///
  256. /// struct MainWindow_Data
  257. struct MainWindow_Data
  258. {
  259.    Object   *win;
  260.    Object   *file;
  261.    Object   *html;
  262.    Object   *scroll;
  263.    Object   *infoline;
  264.    Object   *list;
  265.    Object   *toolbar;
  266.    Object   *tool[4];
  267.  
  268.    char     searchstr[256];
  269.    ULONG    searchpos;
  270.  
  271.    char     path[256];
  272.  
  273.    struct   Config_Data
  274.             cfg;
  275.  
  276.    // Toolbar
  277.    struct   MyList
  278.             *tools;
  279. };
  280. ///
  281.  
  282. // Toolbar
  283.  
  284. /// CreateToolbar
  285. void CreateToolbar(struct MainWindow_Data *data)
  286. {
  287.    FILE     *f;
  288.    static   char
  289.             inbuf[1024],
  290.             buf[1024];
  291.    struct   RDArgs
  292.             rda;
  293.    BOOL     error = TRUE,
  294.             textmode = FALSE,
  295.             virgin = TRUE,
  296.             horiz = TRUE;
  297.  
  298.    struct
  299.    {
  300.       char     *pos;
  301.       ULONG    mode;
  302.       ULONG    space;
  303.       char     *text;
  304.       char     *command;
  305.       ULONG    script;
  306.       char     *key;
  307.       char     *image;
  308.       char     *help;
  309.    } arr;
  310.  
  311.    if(!DataTypesBase) textmode = TRUE;
  312.  
  313.    data->toolbar = data->tool[0];
  314.  
  315.    if(data->tools = MyCreateList(sizeof(struct Tool_Data), 12))
  316.    if(f = fopen("PROGDIR:config/moreHTML.toolbar.config","r"))
  317.    {
  318.       while(!feof(f))
  319.       {
  320.          fgets(inbuf, sizeof(inbuf), f);
  321.          buf[strlen(inbuf)-1] = 0;
  322.  
  323.          if((*stpblk(inbuf) != '#') && (*stpblk(inbuf) != NULL))
  324.          {
  325.             error = FALSE;
  326.  
  327.             memset(&rda, 0, sizeof(struct RDArgs));
  328.             memset(&arr, 0, sizeof(arr));
  329.  
  330.             rda.RDA_Source.CS_Buffer = inbuf;
  331.             rda.RDA_Source.CS_Length = strlen(inbuf);
  332.  
  333.             ReadArgs("POS=POSITION/K,TEXTMODE/S,SPACE/S,TEXT/K,COMMAND/K,SCRIPT/S,KEY/K,IMAGE/K,HELP/K",(LONG *)&arr,&rda);
  334.  
  335.             // Some definitions that have to come before the button definitions
  336.             if(virgin)
  337.             {
  338.                if(arr.pos)
  339.                {
  340.                   if(!stricmp(arr.pos,"left"))
  341.                   {
  342.                      data->toolbar = data->tool[2];
  343.                      horiz = FALSE;
  344.                   }
  345.                   else if(!stricmp(arr.pos,"right"))
  346.                   {
  347.                      data->toolbar = data->tool[3];
  348.                      horiz = FALSE;
  349.                   }
  350.                   else if(!stricmp(arr.pos,"bottom"))
  351.                      data->toolbar = data->tool[1];
  352.                }
  353.                if(arr.mode) textmode=TRUE;
  354.             }
  355.  
  356.             // Kill old contents
  357.             if((arr.space || arr.text) && virgin)
  358.             {
  359.                struct   List
  360.                         *childlist;
  361.                Object   *cstate;
  362.                Object   *child;
  363.  
  364.                if(childlist = (void *)xget(data->toolbar, MUIA_Group_ChildList))
  365.                {
  366.                   cstate = (Object *)childlist->lh_Head;
  367.                   while (child = NextObject(&cstate))
  368.                      DoMethod(data->toolbar, OM_REMMEMBER, child);
  369.                }
  370.                virgin = FALSE;
  371.             }
  372.  
  373.             // Create space
  374.             if(arr.space)
  375.             {
  376.                if(horiz)
  377.                   DoMethod (data->toolbar, OM_ADDMEMBER, HSpace(0));
  378.                else
  379.                   DoMethod (data->toolbar, OM_ADDMEMBER, VSpace(0));
  380.             }
  381.  
  382.             // Create button
  383.             else if(arr.text)
  384.             {
  385.                Object *obj;
  386.                struct Tool_Data *t;
  387.  
  388.                // Buffer the important strings
  389.                // Uses private functions
  390.                t = MyAddItem(data->tools);
  391.                t->command = MyAllocString(arr.command);
  392.                t->help    = MyAllocString(arr.help);
  393.                t->picname = MyAllocString(arr.image);
  394.  
  395.                if(textmode)
  396.                {
  397.                   DoMethod (data->toolbar, OM_ADDMEMBER,
  398.                      obj = TextObject,
  399.                         ButtonFrame,
  400.                         MUIA_Text_Contents, arr.text,
  401.                         MUIA_Text_PreParse, "\33c",
  402.                         MUIA_Text_HiChar  , *arr.key,
  403.                         MUIA_ControlChar  , *arr.key,
  404.                         MUIA_InputMode    , MUIV_InputMode_RelVerify,
  405.                         MUIA_Background   , MUII_ButtonBack,
  406.                         MUIA_CycleChain   , TRUE,
  407.                         MUIA_ShortHelp    , t->help,
  408.                         End
  409.                   );
  410.                }
  411.                else
  412.                {
  413.                   t->image.ibi_ImageType = MUIV_ImageButton_ImageType_File;
  414.                   t->image.ibi_Precision = PRECISION_EXACT;
  415.                   t->image.ibi_UseFriend = TRUE;
  416.                   t->image.ibi_Filename  = t->picname;
  417.  
  418.                   DoMethod (data->toolbar, OM_ADDMEMBER,
  419.                      obj = ImageButtonObject,
  420.                         MUIA_ImageButton_Image, &t->image,
  421.                         MUIA_ImageButton_Label, arr.text,
  422.                         MUIA_CycleChain, TRUE,
  423.                         MUIA_Weight, 0,
  424.                         MUIA_ShortHelp            , t->help,
  425.                         MUIA_ControlChar          , *arr.key,
  426.                         End
  427.                   );
  428.                }
  429.  
  430.                DoMethod(obj, MUIM_Notify, MUIA_Pressed, FALSE,
  431.                   data->win,3,MUIM_MainWindow_Rexx,t->command,arr.script);
  432.             }
  433.  
  434.             FreeArgs(&rda);
  435.          }
  436.       }
  437.       fclose(f);
  438.    }
  439. /*
  440.    else
  441.    {
  442.       puts("Couldn't open toolbar config file.");
  443.    }
  444. */
  445.  
  446.    if(error)
  447.       DoMethod (data->toolbar, OM_ADDMEMBER,
  448.          HSpace(0)
  449.       );
  450. }
  451. ///
  452. /// DisposeToolbar
  453. void DisposeToolbar(struct MainWindow_Data *data)
  454. {
  455.    struct Tool_Data *t;
  456.  
  457.    t = (void *)data->tools->first;
  458.    while(t)
  459.    {
  460.       MyFreeString(t->command);
  461.       MyFreeString(t->help);
  462.       MyFreeString(t->picname);
  463.       t=t->next;
  464.    }
  465.  
  466.    MyDisposeList(data->tools);
  467. }
  468. ///
  469.  
  470. // MainWindow
  471.  
  472. /// OpenURLHook
  473. __saveds ULONG __asm OpenURL(register __a0 struct Hook *h, register __a2 Object *obj, register __a1 struct{ char *URL; char *TmpFilename; } *msg)
  474. {
  475. // struct MainWindow_Data *data = INST_DATA(OCLASS(obj), obj);
  476.    return(TRUE);
  477. }
  478. ///
  479. /// Popobj & List
  480. SAVEDS ASM VOID ObjStrFunc(REG(a2) Object *list,REG(a1) Object *str)
  481. {
  482.    char *x;
  483.    DoMethod(list,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&x);
  484.    set(str,MUIA_String_Contents,x);
  485.    set(str,MUIA_String_Acknowledge,TRUE);
  486. }
  487. ///
  488. /// AppMsgFunc
  489. SAVEDS ASM LONG AppMsgFunc(REG(a2) APTR obj, REG(a1) struct AppMessage **x)
  490. {
  491.    struct WBArg *ap;
  492.    struct AppMessage *amsg = *x;
  493.    static char buf[256];
  494.  
  495.    if(amsg->am_NumArgs)
  496.    {
  497.       ap=amsg->am_ArgList;
  498.       NameFromLock(ap->wa_Lock,buf,sizeof(buf));
  499.       AddPart(buf,ap->wa_Name,sizeof(buf));
  500.       DoMethod(obj,MUIM_MainWindow_Open,buf);
  501.    }
  502.  
  503.    return(0);
  504. }
  505. ///
  506.  
  507. /// SaveHTML
  508. void SaveHTML(struct MainWindow_Data *data, char *name)
  509. {
  510.    if(name)
  511.    {
  512.       char  *text;
  513.       FILE  *f;
  514.  
  515.       get(data->html, MUIA_HTMLtext_Contents, &text);
  516.       if(f=fopen(name,"w"))
  517.       {
  518.          fwrite(text,strlen(text),1,f);
  519.          fclose(f);
  520.       }
  521.    }
  522. }
  523. ///
  524. /// MainWindow_Rexx
  525. ULONG MainWindow_Rexx(struct IClass *cl,Object *obj,struct {ULONG MethodID; char *command; ULONG script;} *msg)
  526. {
  527. //   struct MainWindow_Data *data = INST_DATA(cl,obj);
  528.  
  529.    DB("Command: %s, Script: %ld\n",msg->command,!msg->script);
  530.  
  531.    {
  532.       char     *name, cmd[256];
  533.       FILE     *f;
  534.       Object   *app = (Object *)xget(obj,MUIA_ApplicationObject);
  535.  
  536.       name = TMPREXX;
  537.       if(f = fopen(name,"w"))
  538.       {
  539.          fprintf(f,
  540.             "/* Tmpfile */\n"
  541.             "address %s %s",
  542.             ((char *)xget(app,MUIA_Application_Base)),
  543.             msg->command
  544.          );
  545.          fclose(f);
  546.  
  547.          sprintf(cmd,"run <>nil: sys:rexxc/rx %s",name);
  548.          system(cmd);
  549.       }
  550.    }
  551.  
  552.    return(0);
  553. }
  554. ///
  555. /// MainWindow_Config
  556. ULONG MainWindow_Config(struct IClass *cl,Object *obj,struct {ULONG MethodID; ULONG justget;} *msg)
  557. {
  558.    struct   MainWindow_Data *data = INST_DATA(cl,obj);
  559.    Object   *app = (Object *)xget(obj,MUIA_ApplicationObject);
  560.    char     *h;
  561.    ULONG    d;
  562.  
  563.    Object
  564.       *win,
  565.       *showtoolbar,
  566.       *showinfoline,
  567.       *showimg,
  568.       *viewsource,
  569.       *editsource,
  570.       *printtext;
  571. //    *openurl;
  572.  
  573.    enum
  574.    {
  575.       OBJ_showtoolbar = 1,
  576.       OBJ_showinfoline,
  577.       OBJ_viewsource,
  578.       OBJ_editsource,
  579.       OBJ_printtext,
  580.       OBJ_openurl,
  581.       OBJ_showimg,
  582.    };
  583.  
  584.    static const char *titles[] =
  585.    {
  586.       "Misc",
  587.       "Commands",
  588.       NULL
  589.    };
  590.  
  591.    set(app,MUIA_Application_Sleep,TRUE);  // disable other windows
  592.  
  593.    win =
  594.       WindowObject,
  595.          MUIA_Window_Title, "Settings",
  596.          MUIA_Window_ID   , MAKE_ID('C','O','N','F'),
  597.  
  598.          WindowContents, VGroup,
  599.  
  600.             Child, RegisterObject,
  601.                MUIA_Register_Titles, titles,
  602.  
  603.                // DISPLAY
  604.                Child, ColGroup(2),
  605.                   Child, LLabel("Show _tool bar"),
  606.                   Child, showtoolbar = KeyCheckMark(TRUE,'t'),
  607.                   Child, LLabel("Show info _line"),
  608.                   Child, showinfoline = KeyCheckMark(TRUE,'l'),
  609.                   Child, LLabel("Show _images"),
  610.                   Child, showimg = KeyCheckMark(TRUE,'i'),
  611.                   End,
  612.  
  613.                // FUNCTIONS
  614.                Child, ColGroup(2),
  615.                   Child, VSpace(0),
  616.                   Child, VSpace(0),
  617. /*
  618.                   Child, LLabel("Open URL"),
  619.                   Child, openurl = StringObject,
  620.                      StringFrame,
  621.                      MUIA_CycleChain, 1,
  622.                      MUIA_ObjectID, OBJ_openurl,
  623.                      MUIA_String_Contents, "geturl %s %s",
  624.                      MUIA_ShortHelp,
  625.                         "Command to be used to load page and data\n"
  626.                         "of an to HTMLtext unknown protocol.\n"
  627.                         "First '%s' stands for the URL and the\n"
  628.                         "second '%s' for the file where to write\n"
  629.                         "data to.",
  630.                      End,
  631.                   Child, VSpace(0),
  632.                   Child, VSpace(0),
  633. */
  634.                   Child, LLabel("Print text"),
  635.                   Child, printtext = StringObject,
  636.                      StringFrame,
  637.                      MUIA_CycleChain, 1,
  638.                      MUIA_ObjectID, OBJ_printtext,
  639.                      MUIA_String_Contents, "httx %s prt: ansi",
  640.                      MUIA_ShortHelp,
  641.                         "Command to be used to print the\n"
  642.                         "contents of the current HTML file.\n"
  643.                         "One '%s' has to be used!",
  644.                      End,
  645.                   Child, LLabel("View source"),
  646.                   Child, viewsource = StringObject,
  647.                      StringFrame,
  648.                      MUIA_CycleChain, 1,
  649.                      MUIA_ObjectID, OBJ_viewsource,
  650.                      MUIA_String_Contents, "more %s",
  651.                      MUIA_ShortHelp,
  652.                         "Command to be used to display the\n"
  653.                         "source of the current HTML file.\n"
  654.                         "One '%s' has to be used!",
  655.                      End,
  656.                   Child, LLabel("Edit source"),
  657.                   Child, editsource = StringObject,
  658.                      StringFrame,
  659.                      MUIA_CycleChain, 1,
  660.                      MUIA_ObjectID, OBJ_editsource,
  661.                      MUIA_String_Contents, "ed %s",
  662.                      MUIA_ShortHelp,
  663.                         "Command to be used to edit the\n"
  664.                         "source of the current HTML file.\n"
  665.                         "One '%s' has to be used!",
  666.                      End,
  667. /*
  668.                   Child, printtext = LLabel("On Double-Click"),
  669.                   Child, StringObject,
  670.                      StringFrame,
  671.                      MUIA_CycleChain, 1,
  672.                      MUIA_ObjectID, OBJ_printtext,
  673.                      MUIA_String_Contents, "rx findword.rexx",
  674.                      MUIA_ShortHelp,
  675.                         "Command to be used to print the\n"
  676.                         "contents of the current HTML file.\n"
  677.                         "One '\%s' has to be used!",
  678.                      End,
  679. */
  680.                   Child, VSpace(0),
  681.                   Child, VSpace(0),
  682.                   End,
  683.  
  684.                End,
  685.             End,
  686.          End;
  687.  
  688.    if (win)                               // ok ?
  689.    {
  690.       DoMethod(app,OM_ADDMEMBER,win);    // add window...
  691.       DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE ,
  692.          app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  693.  
  694.       set(showtoolbar,   MUIA_ObjectID, OBJ_showtoolbar);
  695.       set(showtoolbar,   MUIA_CycleChain, 1);
  696.       set(showinfoline,  MUIA_ObjectID, OBJ_showinfoline);
  697.       set(showinfoline,  MUIA_CycleChain, 1);
  698.       set(showimg,       MUIA_ObjectID, OBJ_showimg);
  699.       set(showimg,       MUIA_CycleChain, 1);
  700.  
  701.       DoMethod(app,MUIM_Application_Load, MUIV_Application_Load_ENVARC);
  702.  
  703.       // Just get the config datas
  704.       if(!msg->justget)
  705.       {
  706.  
  707.          set(win,MUIA_Window_Open,TRUE);    // and open it
  708.  
  709.          {
  710.             ULONG sigs = 0;
  711.  
  712.             while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  713.             {
  714.                if (sigs)
  715.                {
  716.                   sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  717.                   if (sigs & SIGBREAKF_CTRL_C) break;
  718.                }
  719.             }
  720.          }
  721.  
  722.          set(win,MUIA_Window_Open,FALSE);   // Close window
  723.  
  724.          DoMethod(app,MUIM_Application_Save, MUIV_Application_Save_ENVARC);
  725.       }
  726.  
  727.       // Read out the config datas
  728.       get(showtoolbar, MUIA_Selected, &d);
  729.       set(data->toolbar, MUIA_ShowMe, d);
  730.  
  731.       get(showinfoline, MUIA_Selected, &d);
  732.       set(data->infoline, MUIA_ShowMe, d);
  733.  
  734.       get(showimg, MUIA_Selected, &d);
  735.       set(data->html, MUIA_HTMLtext_LoadImages, d);
  736.  
  737.       get(viewsource, MUIA_String_Contents, &h);
  738.       strcpy(data->cfg.viewsource, h);
  739.  
  740.       get(editsource, MUIA_String_Contents, &h);
  741.       strcpy(data->cfg.editsource, h);
  742.  
  743.       get(printtext, MUIA_String_Contents, &h);
  744.       strcpy(data->cfg.printtext, h);
  745.  
  746. /*
  747.       get(openurl, MUIA_String_Contents, &h);
  748.       strcpy(data->cfg.openurl, h);
  749.       strcpy(openurlstr, h);
  750. */
  751.       // Remove window
  752.       DoMethod(app,OM_REMMEMBER,win);    // remove
  753.  
  754.       MUI_DisposeObject(win);            // and kill it
  755.    }
  756.    else puts("Couldn't open config window.");
  757.  
  758.    set(app,MUIA_Application_Sleep,FALSE); // wake up the application
  759.    return(0);
  760. }
  761. ///
  762. /// MainWindow_Iconify
  763. ULONG MainWindow_Iconify(struct IClass *cl,Object *obj,struct Msg *msg)
  764. {
  765. // struct MainWindow_Data *data = INST_DATA(cl,obj);
  766.  
  767.    set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Iconified,TRUE);
  768.  
  769.    return(0);
  770. }
  771. ///
  772. /// MainWindow_Finish
  773. ULONG MainWindow_Finish(struct IClass *cl,Object *obj,struct Msg *msg)
  774. {
  775. //   struct MainWindow_Data *data = INST_DATA(cl,obj);
  776.    DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  777.    return(0);
  778. }
  779. ///
  780. /// MainWindow_About
  781. ULONG MainWindow_About(struct IClass *cl,Object *obj,Msg msg)
  782. {
  783.    Object   *app = (Object *)xget(obj,MUIA_ApplicationObject);
  784.    struct   MainWindow_Data
  785.             *data = INST_DATA(cl,obj);
  786.    FILE     *f;
  787.  
  788.    static const char AboutText[] =
  789.       "<HTML>\n"
  790.       "<HEAD><TITLE>"NAME"</TITLE></HEAD>\n"
  791.       "<BODY>\n"
  792.       "<CENTER>\n"
  793.       "<H1>"NAME"</H1><HR>\n"
  794.       "Version %s<BR>\n"
  795.       "%s<BR>\n"
  796.       "Description: %s"
  797.       "<P>\n"
  798.       "<PRE>\n"
  799.       "This program is free software; you can redistribute it  and/or  modify\n"
  800.       "it  under  the terms of the GNU General Public License as published by\n"
  801.       "the Free Software Foundation; either version 2 of the License, or  (at\n"
  802.       "your option) any later version.\n"
  803.       "\n"
  804.       "This program is distributed in the hope that it will  be  useful,  but\n"
  805.       "WITHOUT   ANY   WARRANTY;   without   even  the  implied  warranty  of\n"
  806.       "MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PURPOSE.  See  the  GNU\n"
  807.       "General Public License for more details.\n"
  808.       "</PRE>\n"
  809.       "</P>\n"
  810.       "ARexx-Port: %s\n"
  811.       "</BODY>\n"
  812.       "</HTML>\n";
  813.  
  814.  
  815.    if(f = fopen(TMPINFO,"w"))
  816.    {
  817.       fprintf(f,
  818.          (char *)AboutText,
  819.          ((char *)xget(app,MUIA_Application_Version))+7+strlen(NAME),
  820.          ((char *)xget(app,MUIA_Application_Copyright)),
  821.          ((char *)xget(app,MUIA_Application_Description)),
  822.          ((char *)xget(app,MUIA_Application_Base)));
  823.       fclose(f);
  824.  
  825.       set(data->html, MUIA_HTMLtext_URL, TMPINFO);
  826.    }
  827.  
  828.    return(0);
  829. }
  830. ///
  831. /// MainWindow_AddURL
  832. ULONG MainWindow_AddURL(struct IClass *cl,Object *obj,struct {ULONG MethodID; ULONG fstr;} *msg)
  833. {
  834.    struct MainWindow_Data *data = INST_DATA(cl,obj);
  835.    char   *url;
  836.    ULONG  x;
  837.  
  838.    // from string
  839.    if(msg->fstr)
  840.    {
  841.       set(data->html, MUIA_HTMLtext_URL, xget(data->file, MUIA_String_Contents));
  842.    }
  843.  
  844.    url = (char *)xget(data->html, MUIA_HTMLtext_URL);
  845.    set(data->file, MUIA_String_Contents, url);
  846.  
  847.    // history
  848.    if(url && *url)
  849.    {
  850.       set(data->list, MUIA_List_Quiet, TRUE);
  851.       if((x = xget(data->list, MUIA_List_Active))!=MUIV_List_Active_Off)
  852.       {
  853.          while(x)
  854.          {
  855.             DoMethod(data->list, MUIM_List_Remove, MUIV_List_Remove_First);
  856.             --x;
  857.          }
  858.       }
  859.  
  860.       DoMethod(data->list,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&x);
  861.  
  862.       if(!x || stricmp((char *)x,url))
  863.          DoMethod(data->list, MUIM_List_InsertSingle, url, MUIV_List_Insert_Top);
  864.  
  865.       set(data->list, MUIA_List_Active, MUIV_List_Active_Top);
  866.       set(data->list, MUIA_List_Quiet, FALSE);
  867.    }
  868.  
  869.    return(0);
  870. }
  871. ///
  872. /// MainWindow_ShowURL
  873. enum
  874. {
  875.    SHOW_back,
  876.    SHOW_forward,
  877.    SHOW_active
  878. };
  879.  
  880. ULONG MainWindow_ShowURL(struct IClass *cl,Object *obj,struct {ULONG MethodID; ULONG mode;} *msg)
  881. {
  882.    struct MainWindow_Data *data = INST_DATA(cl,obj);
  883.    ULONG  x;
  884.  
  885.    switch(msg->mode)
  886.    {
  887.       case SHOW_back:
  888.          set(data->list, MUIA_List_Active, MUIV_List_Active_Down);
  889.          break;
  890.       case SHOW_forward:
  891.          set(data->list, MUIA_List_Active, MUIV_List_Active_Up);
  892.          break;
  893.    }
  894.  
  895.    DoMethod(data->list,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&x);
  896.    set(data->html,MUIA_HTMLtext_URL,x);
  897.    set(data->file,MUIA_String_Contents,x);
  898.    return(0);
  899. }
  900. ///
  901. /// MainWindow_ReloadURL
  902. ULONG MainWindow_ReloadURL(struct IClass *cl,Object *obj,Msg msg)
  903. {
  904.    struct MainWindow_Data *data = INST_DATA(cl,obj);
  905.  
  906.    DoMethod(data->html, MUIM_HTMLtext_Reload);
  907.    return(0);
  908. }
  909. ///
  910. /// IntuiMsgFunc
  911. SAVEDS ASM VOID IntuiMsgFunc(REG(a1) struct IntuiMessage *imsg,REG(a2) struct FileRequester *req)
  912. {
  913.    if (imsg->Class==IDCMP_REFRESHWINDOW)
  914.       DoMethod(req->fr_UserData,MUIM_Application_CheckRefresh);
  915. }
  916. ///
  917. /// getfilename
  918. char *getfilename(char *title,BOOL save, char *path)
  919. {
  920.    static char buf[512];
  921.    struct FileRequester *req;
  922.    struct Window *w;
  923.    static LONG left=-1,top=-1,width=-1,height=-1;
  924.    Object *app = (Object *)xget(win,MUIA_ApplicationObject);
  925.    char *res = NULL;
  926.    static const struct Hook IntuiMsgHook = { { 0,0 },(VOID *)IntuiMsgFunc,NULL,NULL };
  927.  
  928.    get(win,MUIA_Window_Window,&w);
  929.    if (left==-1)
  930.    {
  931.       left   = w->LeftEdge+w->BorderLeft+2;
  932.       top    = w->TopEdge+w->BorderTop+2;
  933.       width  = w->Width-w->BorderLeft-w->BorderRight-4;
  934.       height = w->Height-w->BorderTop-w->BorderBottom-4;
  935.    }
  936.  
  937.    if (req=MUI_AllocAslRequestTags(ASL_FileRequest,
  938.       ASLFR_Window, w,
  939.       ASLFR_TitleText, title,
  940.       ASLFR_InitialLeftEdge, left,
  941.       ASLFR_InitialTopEdge , top,
  942.       ASLFR_InitialWidth   , width,
  943.       ASLFR_InitialHeight  , height,
  944.       ASLFR_InitialDrawer  , path,
  945.       ASLFR_InitialPattern , "#?.(html|htm)",
  946.       ASLFR_DoSaveMode     , save,
  947.       ASLFR_DoPatterns     , TRUE,
  948.       ASLFR_RejectIcons    , TRUE,
  949.       ASLFR_UserData       , app,
  950.       ASLFR_IntuiMsgFunc   , &IntuiMsgHook,
  951.       TAG_DONE))
  952.    {
  953.       set(app,MUIA_Application_Sleep,TRUE);
  954.       if (MUI_AslRequestTags(req,TAG_DONE))
  955.       {
  956.          if (*req->fr_File)
  957.          {
  958.             res = buf;
  959.             stccpy(path,req->fr_Drawer,255);
  960.             stccpy(buf,req->fr_Drawer,sizeof(buf));
  961.             AddPart(buf,req->fr_File,sizeof(buf));
  962.          }
  963.          left   = req->fr_LeftEdge;
  964.          top    = req->fr_TopEdge;
  965.          width  = req->fr_Width;
  966.          height = req->fr_Height;
  967.       }
  968.       MUI_FreeAslRequest(req);
  969.       set(app,MUIA_Application_Sleep,FALSE);
  970.    }
  971.    return(res);
  972. }
  973. ///
  974. /// MainWindow_Action
  975. enum
  976. {
  977.    ACTION_clipblock,
  978.    ACTION_clipsrc,
  979.    ACTION_print,
  980.    ACTION_viewsrc,
  981.    ACTION_editsrc,
  982.    ACTION_geturl,
  983.    ACTION_printsrc,
  984. };
  985.  
  986. ULONG MainWindow_Action(struct IClass *cl,Object *obj,struct {ULONG MethodID; ULONG mode;} *msg)
  987. {
  988.    struct   MainWindow_Data *data = INST_DATA(cl,obj);
  989.    char     buf[120], *text, tmpname[60];
  990.  
  991.    switch(msg->mode)
  992.    {
  993.       // Clip block
  994.       case ACTION_clipblock:
  995.          get(data->html, MUIA_HTMLtext_Block, &text);
  996.          WriteClip(text);
  997.          break;
  998.  
  999.       // Clip source
  1000.       case ACTION_clipsrc:
  1001.          get(data->html, MUIA_HTMLtext_Contents, &text);
  1002.          WriteClip(text);
  1003.          break;
  1004.  
  1005.       // Print text
  1006.       case ACTION_print:
  1007.          tmpnam(tmpname);
  1008.          SaveHTML(data, tmpname);
  1009.          sprintf(buf, data->cfg.printtext, tmpname);
  1010.          if(buf[0]) system(buf);
  1011.          remove(tmpname);
  1012.          break;
  1013.  
  1014.       // Print source
  1015.       case ACTION_printsrc:
  1016.          SaveHTML(data, "prt:");
  1017.          break;
  1018.  
  1019.       // View source
  1020.       case ACTION_viewsrc:
  1021.          tmpnam(tmpname);
  1022.          SaveHTML(data, tmpname);
  1023.          sprintf(buf, data->cfg.viewsource, tmpname);
  1024.          if(buf[0]) system(buf);
  1025.          remove(tmpname);
  1026.          break;
  1027.  
  1028.       // Edit source
  1029.       case ACTION_editsrc:
  1030.          {
  1031.             char  *url;
  1032.  
  1033.             get(data->html, MUIA_HTMLtext_URL, &url);
  1034.             if(url)
  1035.             {
  1036.                sprintf(buf, data->cfg.editsource, url);
  1037.                if(buf[0]) system(buf);
  1038.                DoMethod(obj, MUIM_MainWindow_ReloadURL, 0);
  1039.             }
  1040.          }
  1041.          break;
  1042.  
  1043.       // Get URL
  1044.       case ACTION_geturl:
  1045.          {
  1046.             ULONG url;
  1047.  
  1048.             get(data->html, MUIA_HTMLtext_URL, &url);
  1049.             return(url);
  1050.          }
  1051.          break;
  1052.    }
  1053.    return(0);
  1054. }
  1055. ///
  1056. /// MainWindow_Find
  1057. enum
  1058. {
  1059.    FIND_new = 1,
  1060.    FIND_word,
  1061.    FIND_next,
  1062.    FIND_first
  1063. };
  1064.  
  1065. ULONG Search(struct MainWindow_Data *data, STRPTR searchstr, ULONG pos, ULONG flags)
  1066. {
  1067.    struct MUIS_HTMLtext_Element *el; //, *ell;
  1068. // Object *app = (Object *)xget(data->html,MUIA_ApplicationObject);
  1069. // char  *str;
  1070.  
  1071.    if(searchstr && *searchstr)
  1072.    {
  1073. //    set(app, MUIA_Application_Sleep, TRUE);
  1074.       get(data->html, MUIA_HTMLtext_ElementList, &el);
  1075.       while(el)
  1076.       {
  1077.          if(!strnicmp(MACRO_HTMLtext_GetText(el), searchstr, strlen(searchstr)))
  1078.          {
  1079.             if(pos)
  1080.                pos--;
  1081.             else
  1082.             {
  1083.                DoMethod(data->html, MUIM_HTMLtext_Mark, el, el);
  1084.                DoMethod(data->html, MUIM_HTMLtext_Jump, el);
  1085.                return(TRUE);
  1086.             }
  1087.          }
  1088.          el = el->next;
  1089.       }
  1090. //    set(app, MUIA_Application_Sleep, FALSE);
  1091.    }
  1092.  
  1093.    return(FALSE);
  1094. }
  1095.  
  1096. ULONG MainWindow_Find(struct IClass *cl,Object *obj,struct {ULONG MethodID; ULONG mode; char *str;} *msg)
  1097. {
  1098.    Object *app = (Object *)xget(obj,MUIA_ApplicationObject);
  1099.    struct MainWindow_Data *data = INST_DATA(cl,obj);
  1100.  
  1101.    switch(msg->mode)
  1102.    {
  1103.       case FIND_new:
  1104.          // Open window and ask
  1105.          {
  1106.             Object   *win, *searchstr, *start;
  1107.             char     *str;
  1108.  
  1109.             set(app,MUIA_Application_Sleep,TRUE);  // disable other windows
  1110.  
  1111.             win =
  1112.                WindowObject,
  1113.                   MUIA_Window_Title, "Find",
  1114.                   MUIA_Window_ID   , MAKE_ID('F','I','N','D'),
  1115.  
  1116.                   WindowContents, VGroup,
  1117.                      Child, LLabel("Find this string:"),
  1118.                      Child, searchstr = StringObject,
  1119.                         StringFrame,
  1120.                         MUIA_CycleChain, 1,
  1121.                         MUIA_String_AdvanceOnCR, TRUE,
  1122.                         MUIA_String_Contents, data->searchstr,
  1123.                         MUIA_ShortHelp, "Will find all words in the text\nbeginning with this string",
  1124.                         End,
  1125.                      Child, start = SimpleButton("_Start"),
  1126.                      End,
  1127.                   End;
  1128.  
  1129.             if (win)                               // ok ?
  1130.             {
  1131.                DoMethod(app,OM_ADDMEMBER,win);    // add window...
  1132.                DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE ,
  1133.                   app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  1134.                DoMethod(start, MUIM_Notify, MUIA_Pressed, FALSE,
  1135.                   app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  1136.  
  1137.                set(start,MUIA_CycleChain, 1);
  1138.                set(win,MUIA_Window_Open,TRUE);    // and open it
  1139.                set(win,MUIA_Window_ActiveObject, searchstr);
  1140.  
  1141.                {
  1142.                   ULONG sigs = 0;
  1143.  
  1144.                   while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  1145.                   {
  1146.                      if (sigs)
  1147.                      {
  1148.                         sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  1149.                         if (sigs & SIGBREAKF_CTRL_C) break;
  1150.                      }
  1151.                   }
  1152.                }
  1153.  
  1154.                set(win,MUIA_Window_Open,FALSE);   // Close window
  1155.  
  1156.                get(searchstr, MUIA_String_Contents, &str);
  1157.                stccpy(data->searchstr, str, sizeof(data->searchstr));
  1158.  
  1159.                // Remove window
  1160.                DoMethod(app,OM_REMMEMBER,win);    // remove
  1161.  
  1162.                MUI_DisposeObject(win);            // and kill it
  1163.             }
  1164.             else puts("Couldn't open search window.");
  1165.  
  1166.             set(app,MUIA_Application_Sleep,FALSE); // wake up the application
  1167.          }
  1168.  
  1169.       case FIND_first:
  1170.          data->searchpos = 0;
  1171.          break;
  1172.  
  1173.       case FIND_word:
  1174.          // Take word from string (AREXX)
  1175.          stccpy(data->searchstr, msg->str, sizeof(data->searchstr));
  1176.          data->searchpos = 0;
  1177.          break;
  1178.  
  1179.    }
  1180.  
  1181.    // Suchen und erhöhen
  1182.    if(!Search(data, data->searchstr, data->searchpos++, 0))
  1183.    {
  1184.       // Am Ende angelang wieder das erste zeigen
  1185.       if(data->searchpos)
  1186.       {
  1187.          data->searchpos = 0;
  1188.          Search(data, data->searchstr, data->searchpos++, 0);
  1189.       }
  1190.       else REQ("String can't be found!","*_OK");
  1191.    }
  1192.  
  1193.    return(0);
  1194. }
  1195. ///
  1196. /// MainWindow_Open
  1197. ULONG MainWindow_Open(struct IClass *cl,Object *obj,struct {ULONG MethodID; char *name;} *msg)
  1198. {
  1199.    struct MainWindow_Data *data = INST_DATA(cl,obj);
  1200.    char *name;
  1201.  
  1202.    if(msg->name)
  1203.    {
  1204.       // name comes as argument
  1205.       name = msg->name;
  1206.    }
  1207.    else
  1208.    {
  1209.       // filerequester
  1210.       name = getfilename("Select local file",FALSE,data->path);
  1211.    }
  1212.  
  1213.    if(name)
  1214.    {
  1215.       set(data->file, MUIA_String_Contents, name);
  1216.       DoMethod(obj, MUIM_MainWindow_AddURL, 1);
  1217.    }
  1218.  
  1219.    return(0);
  1220. }
  1221. ///
  1222. /// MainWindow_Save
  1223. ULONG MainWindow_Save(struct IClass *cl,Object *obj,struct {ULONG MethodID; char *name;} *msg)
  1224. {
  1225.    struct MainWindow_Data *data = INST_DATA(cl,obj);
  1226.    char *name;
  1227.  
  1228.    if(msg->name)
  1229.    {
  1230.       name = msg->name;
  1231.    }
  1232.    else
  1233.    {
  1234.       name = getfilename("Select local file",TRUE,data->path);
  1235.    }
  1236.  
  1237.    SaveHTML(data, name);
  1238.    return(0);
  1239. }
  1240. ///
  1241. /// MainWindow_Dispose
  1242. ULONG MainWindow_Dispose(struct IClass *cl,Object *obj,Msg msg)
  1243. {
  1244.    struct MainWindow_Data *data = INST_DATA(cl,obj);
  1245.  
  1246.    DB("Dispose\n");
  1247.  
  1248.    // remove toolbar
  1249.    DisposeToolbar(data);
  1250.  
  1251.    DB("End Dispose\n");
  1252.  
  1253.    return(DoSuperMethodA(cl,obj,msg));
  1254. }
  1255. ///
  1256. /// MainWindow_New
  1257. ULONG MainWindow_New(struct IClass *cl,Object *obj,struct opSet *msg)
  1258. {
  1259.    Object *strip;
  1260.    struct MainWindow_Data tmp = {0};
  1261. /*
  1262.    static const struct Hook OpenURLHook
  1263.       = { { NULL,NULL },(VOID *)OpenURL ,NULL,NULL };
  1264. */
  1265.    static const struct Hook AppMsgHook
  1266.       = { { NULL,NULL },(VOID *)AppMsgFunc,NULL,NULL };
  1267.  
  1268.    if (obj = (Object *)DoSuperNew(cl,obj,
  1269.          MUIA_Window_Title, "MoreHTML © Dirk Holtwick, 1997",
  1270.          MUIA_Window_ID   , MAKE_ID('H','T','M','L'),
  1271.          MUIA_Window_UseRightBorderScroller, TRUE,
  1272.          MUIA_Window_UseBottomBorderScroller, TRUE,
  1273.          MUIA_Window_Menustrip, strip = MUI_MakeObject(MUIO_MenustripNM,MainMenu,0),
  1274.          MUIA_Window_AppWindow, TRUE,
  1275.  
  1276.          WindowContents, HGroup,
  1277.             Child, tmp.tool[2] = VGroup,
  1278.                MUIA_VertWeight, 1,
  1279.                Child, VSpace(0),
  1280.                End,
  1281.             Child, VGroup,
  1282.                Child, tmp.tool[0] = HGroup,
  1283.                   Child, HSpace(0),
  1284.                   End,
  1285.  
  1286.                // Infoline
  1287.                Child, tmp.infoline = PopobjectObject,
  1288.                   MUIA_Popstring_String, tmp.file = NewStringObject,
  1289.                      StringFrame,
  1290.                      MUIA_CycleChain, 1,
  1291.                      MUIA_String_MaxLen, 1024,
  1292.                      End,
  1293.                   MUIA_Popstring_Button, PopButton(MUII_PopUp),
  1294.                   MUIA_Popobject_Object, ListviewObject,
  1295.                      MUIA_Listview_List, tmp.list = ListObject,
  1296.                         InputListFrame,
  1297.                         MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
  1298.                         MUIA_List_DestructHook, MUIV_List_DestructHook_String,
  1299.                         End,
  1300.                      End,
  1301.                   End,
  1302.  
  1303.                // HTML object with ScrollGroup
  1304.                Child, tmp.scroll = ScrollgroupObject,
  1305.                   MUIA_CycleChain, 1,
  1306.                   MUIA_Scrollgroup_UseWinBorder, TRUE,
  1307.                   MUIA_Scrollgroup_Contents, tmp.html = HTMLtextObject,
  1308.                      TextFrame,
  1309. //                   MUIA_HTMLtext_OpenURLHook, &OpenURLHook,
  1310.                      End,
  1311.                   End,
  1312.  
  1313.                Child, tmp.tool[1] = HGroup,
  1314.                   Child, HSpace(0),
  1315.                   End,
  1316.                End,
  1317.             Child, tmp.tool[3] = VGroup,
  1318.                MUIA_VertWeight, 1,
  1319.                Child, VSpace(0),
  1320.                End,
  1321.             End,
  1322.  
  1323.          TAG_MORE,msg->ops_AttrList))
  1324.    {
  1325.       struct MainWindow_Data *data = INST_DATA(cl,obj);
  1326.  
  1327.       *data = tmp;
  1328.  
  1329.       data->win = obj;
  1330.  
  1331.       // Add toolbar
  1332.       CreateToolbar(data);
  1333.  
  1334.       // Methods
  1335.       DoMethod(obj,MUIM_Notify,MUIA_Window_CloseRequest,TRUE ,
  1336.          obj,2,MUIM_MainWindow_Finish, 0);
  1337.  
  1338.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_ABOUT    ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1339.          obj,1,MUIM_MainWindow_About);
  1340.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_OPEN     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1341.          obj,2,MUIM_MainWindow_Open,0);
  1342.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_SAVE     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1343.          obj,2,MUIM_MainWindow_Save,0);
  1344.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_HIDE     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1345.          obj,1,MUIM_MainWindow_Iconify);
  1346.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_QUIT     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1347.          obj,2,MUIM_MainWindow_Finish,0);
  1348.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_FIND     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1349.          obj,3,MUIM_MainWindow_Find,FIND_new,0);
  1350.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_NEXT     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1351.          obj,3,MUIM_MainWindow_Find,FIND_next,0);
  1352.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_CPTEXT   ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1353.          obj,2,MUIM_MainWindow_Action,ACTION_clipsrc);
  1354.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_CPBLOCK  ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1355.          obj,2,MUIM_MainWindow_Action,ACTION_clipblock);
  1356.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_PRINT    ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1357.          obj,2,MUIM_MainWindow_Action,ACTION_print);
  1358.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_PRSRC    ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1359.          obj,2,MUIM_MainWindow_Action,ACTION_printsrc);
  1360.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_VIEW     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1361.          obj,2,MUIM_MainWindow_Action,ACTION_viewsrc);
  1362.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_EDIT     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1363.          obj,2,MUIM_MainWindow_Action,ACTION_editsrc);
  1364.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_BACK     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1365.          obj,2,MUIM_MainWindow_ShowURL, SHOW_back);
  1366.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_FORWARD  ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1367.          obj,2,MUIM_MainWindow_ShowURL, SHOW_forward);
  1368.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_RELOAD   ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1369.          obj,1,MUIM_MainWindow_ReloadURL);
  1370.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_CONF     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1371.          obj,1,MUIM_MainWindow_Config, FALSE);
  1372.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_AMUI     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1373.          MUIV_Notify_Application,2,MUIM_Application_AboutMUI,obj);
  1374.       DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_MUI      ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
  1375.          MUIV_Notify_Application,2,MUIM_Application_OpenConfigWindow,0);
  1376.  
  1377.       // Popobj
  1378.       DoMethod(data->list,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,
  1379.          data->infoline,2,MUIM_Popstring_Close,TRUE);
  1380.  
  1381.       // Clicked
  1382.       DoMethod(data->html,MUIM_Notify,MUIA_HTMLtext_Clicked,TRUE,
  1383.          obj,2,MUIM_MainWindow_AddURL,0);
  1384.  
  1385.       // Title
  1386.       DoMethod(data->html,MUIM_Notify,MUIA_HTMLtext_Title,MUIV_EveryTime,
  1387.          obj,3,MUIM_Set,MUIA_Window_Title,MUIV_TriggerValue);
  1388.  
  1389.       // String
  1390.       DoMethod(data->file, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1391.          obj,2,MUIM_MainWindow_AddURL,1);
  1392.  
  1393.       // History
  1394.       DoMethod(data->list, MUIM_Notify, MUIA_Listview_DoubleClick, MUIV_EveryTime,
  1395.          obj,2,MUIM_MainWindow_ShowURL,SHOW_active);
  1396.  
  1397.       // App Msg
  1398.       DoMethod(obj,MUIM_Notify,MUIA_AppMessage,MUIV_EveryTime,
  1399.          obj,3,MUIM_CallHook,&AppMsgHook,MUIV_TriggerValue);
  1400.  
  1401.       set(obj,MUIA_Window_ActiveObject,data->scroll);
  1402.       set(obj,MUIA_Window_DefaultObject,data->scroll);
  1403.  
  1404.       return((ULONG)obj);
  1405.    }
  1406.    return(0);
  1407. }
  1408. ///
  1409. /// MainWindow_Dispatcher
  1410. SAVEDS ASM ULONG MainWindow_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  1411. {
  1412.    switch (msg->MethodID)
  1413.    {
  1414.       case OM_NEW                   : return(MainWindow_New       (cl,obj,(APTR)msg));
  1415.       case OM_DISPOSE               : return(MainWindow_Dispose   (cl,obj,(APTR)msg));
  1416.       case MUIM_MainWindow_Finish   : return(MainWindow_Finish    (cl,obj,(APTR)msg));
  1417.       case MUIM_MainWindow_Iconify  : return(MainWindow_Iconify   (cl,obj,(APTR)msg));
  1418.       case MUIM_MainWindow_About    : return(MainWindow_About     (cl,obj,(APTR)msg));
  1419.       case MUIM_MainWindow_AddURL   : return(MainWindow_AddURL    (cl,obj,(APTR)msg));
  1420.       case MUIM_MainWindow_ShowURL  : return(MainWindow_ShowURL   (cl,obj,(APTR)msg));
  1421.       case MUIM_MainWindow_ReloadURL: return(MainWindow_ReloadURL (cl,obj,(APTR)msg));
  1422.       case MUIM_MainWindow_Open     : return(MainWindow_Open      (cl,obj,(APTR)msg));
  1423.       case MUIM_MainWindow_Save     : return(MainWindow_Save      (cl,obj,(APTR)msg));
  1424.       case MUIM_MainWindow_Config   : return(MainWindow_Config    (cl,obj,(APTR)msg));
  1425.       case MUIM_MainWindow_Action   : return(MainWindow_Action    (cl,obj,(APTR)msg));
  1426.       case MUIM_MainWindow_Find     : return(MainWindow_Find      (cl,obj,(APTR)msg));
  1427.       case MUIM_MainWindow_Rexx     : return(MainWindow_Rexx      (cl,obj,(APTR)msg));
  1428.    }
  1429.    return(DoSuperMethodA(cl,obj,msg));
  1430. }
  1431.  
  1432. ///
  1433.  
  1434. // ARexx
  1435.  
  1436. /// Rexx_URL
  1437. SAVEDS ASM LONG Rexx_URL (REG(a2) Object *app)
  1438. {
  1439.    set(app, MUIA_Application_RexxString,
  1440.       DoMethod(win, MUIM_MainWindow_Action, ACTION_geturl));
  1441.    return(0);
  1442. }
  1443. ///
  1444. /// Rexx_Save
  1445. SAVEDS ASM LONG Rexx_Save (REG(a1) struct {char *name;} *msg)
  1446. {
  1447.    if(msg->name)
  1448.       DoMethod(win, MUIM_MainWindow_Save, msg->name);
  1449.    else
  1450.       DoMethod(win, MUIM_MainWindow_Save, 0);
  1451.  
  1452.    return(0);
  1453. }
  1454. ///
  1455. /// Rexx_Open
  1456. SAVEDS ASM LONG Rexx_Open(REG(a1) struct {char *name;} *msg)
  1457. {
  1458.    if(msg->name)
  1459.       DoMethod(win, MUIM_MainWindow_Open, msg->name);
  1460.    else
  1461.       DoMethod(win, MUIM_MainWindow_Open, 0);
  1462.  
  1463.    return(0);
  1464. }
  1465. ///
  1466. /// Rexx_Find
  1467. SAVEDS ASM LONG Rexx_Find (REG(a1) struct {char *str; LONG first; LONG next;} *msg)
  1468. {
  1469.    if(msg->str)
  1470.       DoMethod(win, MUIM_MainWindow_Find, FIND_word, msg->str);
  1471.    else if(msg->first)
  1472.       DoMethod(win, MUIM_MainWindow_Find, FIND_first, 0);
  1473.    else if(msg->next)
  1474.       DoMethod(win, MUIM_MainWindow_Find, FIND_next, 0);
  1475.    else
  1476.       DoMethod(win, MUIM_MainWindow_Find, FIND_new, 0);
  1477.    return(0);
  1478. }
  1479. ///
  1480. /// Rexx_Print
  1481. SAVEDS ASM LONG Rexx_Print(REG(a1) Msg msg)
  1482. {
  1483.    DoMethod(win, MUIM_MainWindow_Action, ACTION_print);
  1484.    return(0);
  1485. }
  1486. ///
  1487. /// Rexx_View
  1488. SAVEDS ASM LONG Rexx_View(REG(a1) Msg msg)
  1489. {
  1490.    DoMethod(win, MUIM_MainWindow_Action, ACTION_viewsrc);
  1491.    return(0);
  1492. }
  1493. ///
  1494. /// Rexx_Reload
  1495. SAVEDS ASM LONG Rexx_Reload(REG(a1) Msg msg)
  1496. {
  1497.    DoMethod(win, MUIM_MainWindow_ReloadURL);
  1498.    return(0);
  1499. }
  1500. ///
  1501. /// Rexx_Back
  1502. SAVEDS ASM LONG Rexx_Back(REG(a1) Msg msg)
  1503. {
  1504.    DoMethod(win, MUIM_MainWindow_ShowURL, SHOW_back);
  1505.    return(0);
  1506. }
  1507. ///
  1508. /// Rexx_Forward
  1509. SAVEDS ASM LONG Rexx_Forward(REG(a1) Msg msg)
  1510. {
  1511.    DoMethod(win, MUIM_MainWindow_ShowURL, SHOW_forward);
  1512.    return(0);
  1513. }
  1514. ///
  1515. /// Rexx_Edit
  1516. SAVEDS ASM LONG Rexx_Edit(REG(a1) Msg msg)
  1517. {
  1518.    DoMethod(win, MUIM_MainWindow_Action, ACTION_editsrc);
  1519.    return(0);
  1520. }
  1521. ///
  1522.  
  1523. // Init
  1524.  
  1525. /// ExitLibs
  1526. VOID ExitLibs(VOID)
  1527. {
  1528.    if (IntuitionBase) CloseLibrary(IntuitionBase);
  1529.    if (GfxBase      ) CloseLibrary(GfxBase      );
  1530.    if (AslBase      ) CloseLibrary(AslBase      );
  1531.    if (UtilityBase  ) CloseLibrary(UtilityBase  );
  1532.    if (MUIMasterBase) CloseLibrary(MUIMasterBase);
  1533.    if (DataTypesBase) CloseLibrary(DataTypesBase);
  1534. }
  1535. ///
  1536. /// InitLibs
  1537. BOOL InitLibs(VOID)
  1538. {
  1539.    MUIMasterBase = OpenLibrary("muimaster.library",11);
  1540.    UtilityBase   = OpenLibrary("utility.library"  ,36);
  1541.    AslBase       = OpenLibrary("asl.library"      ,36);
  1542.    GfxBase       = OpenLibrary("graphics.library" ,36);
  1543.    IntuitionBase = OpenLibrary("intuition.library",36);
  1544.    DataTypesBase = OpenLibrary("datatypes.library",0);
  1545.  
  1546.    if (MUIMasterBase && UtilityBase && AslBase && GfxBase && IntuitionBase)
  1547.       return(TRUE);
  1548.  
  1549.    ExitLibs();
  1550.    return(FALSE);
  1551. }
  1552. ///
  1553. /// ExitClasses
  1554. VOID ExitClasses(VOID)
  1555. {
  1556.    if (CL_MainWindow  )    MUI_DeleteCustomClass(CL_MainWindow  );
  1557. }
  1558. ///
  1559. /// InitClasses
  1560. BOOL InitClasses(VOID)
  1561. {
  1562.    CL_MainWindow   = MUI_CreateCustomClass(NULL,MUIC_Window    ,NULL,sizeof(struct MainWindow_Data  )    ,MainWindow_Dispatcher  );
  1563.  
  1564.    if (CL_MainWindow)
  1565.       return(TRUE);
  1566.  
  1567.    ExitClasses();
  1568.    return(FALSE);
  1569. }
  1570. ///
  1571. /// HandleArgs
  1572. const char CLITemplate[] = "URL";
  1573.  
  1574. const char CLIHelp[] =
  1575.    "\n"
  1576.    "\033[1mmoreHTML " VERS "\033[0m\n"
  1577.    "(C)opyright by Dirk Holtwick, 1997\n"
  1578.    "\n"
  1579.    "Usage: moreHTML <url>\n"
  1580.    " <url>   : filename or URL of the file to be displayed\n";
  1581.  
  1582. LONG HandleArgs(char *filename)
  1583. {
  1584.    struct RDArgs *rda,*rdas;
  1585.    LONG msg = 0;
  1586.  
  1587.    struct CLIArgs
  1588.    {
  1589.       char *url;
  1590.    } argarray = { 0 };
  1591.  
  1592.    if (rdas = AllocDosObject(DOS_RDARGS,NULL))
  1593.    {
  1594.       rdas->RDA_ExtHelp = (char *)CLIHelp;
  1595.  
  1596.       if (rda = ReadArgs((char *)CLITemplate,(LONG *)&argarray,rdas))
  1597.       {
  1598.          if (argarray.url)
  1599.          {
  1600.             strcpy(filename, argarray.url);
  1601.          }
  1602.          FreeArgs(rda);
  1603.       }
  1604.       FreeDosObject(DOS_RDARGS,rdas);
  1605.    }
  1606.    return(msg);
  1607. }
  1608. ///
  1609.  
  1610. // Main
  1611.  
  1612. /// Main Program
  1613.  
  1614. int main(int argc,char *argv[])
  1615. {
  1616.    struct   WBStartup *wbmsg;
  1617.    ULONG    sigs=0, id;
  1618.    Object   *app;
  1619.    int      res;
  1620.    int      msg=0;
  1621.    char     filename[256];
  1622.  
  1623.    static const struct Hook Rexx_URLHook       = { { NULL,NULL },(VOID *)Rexx_URL     ,NULL,NULL };
  1624.    static const struct Hook Rexx_SaveHook      = { { NULL,NULL },(VOID *)Rexx_Save    ,NULL,NULL };
  1625.    static const struct Hook Rexx_OpenHook      = { { NULL,NULL },(VOID *)Rexx_Open    ,NULL,NULL };
  1626.    static const struct Hook Rexx_PrintHook     = { { NULL,NULL },(void *)Rexx_Print   ,NULL,NULL };
  1627.    static const struct Hook Rexx_BackHook      = { { NULL,NULL },(void *)Rexx_Back    ,NULL,NULL };
  1628.    static const struct Hook Rexx_ForwardHook   = { { NULL,NULL },(void *)Rexx_Forward ,NULL,NULL };
  1629.    static const struct Hook Rexx_ReloadHook    = { { NULL,NULL },(void *)Rexx_Reload  ,NULL,NULL };
  1630.    static const struct Hook Rexx_ViewHook      = { { NULL,NULL },(void *)Rexx_View    ,NULL,NULL };
  1631.    static const struct Hook Rexx_FindHook      = { { NULL,NULL },(void *)Rexx_Find    ,NULL,NULL };
  1632.    static const struct Hook Rexx_EditHook      = { { NULL,NULL },(void *)Rexx_Edit    ,NULL,NULL };
  1633.  
  1634.    // ARexx commands
  1635.    static struct MUI_Command commands[] =
  1636.    {
  1637.       { "url"       ,""                    , 0        , (void *)&Rexx_URLHook     },
  1638.       { "save"      ,"file/k"              , 1        , (void *)&Rexx_SaveHook    },
  1639.       { "open"      ,"url=file/k"          , 1        , (void *)&Rexx_OpenHook    },
  1640.       { "find"      ,"string=word/k,first=top/s,next/s"
  1641.                                            , 3        , (void *)&Rexx_FindHook    },
  1642.       { "print"     ,""                    , 0        , (void *)&Rexx_PrintHook   },
  1643.       { "back"      ,""                    , 0        , (void *)&Rexx_BackHook    },
  1644.       { "forward"   ,""                    , 0        , (void *)&Rexx_ForwardHook },
  1645.       { "reload"    ,""                    , 0        , (void *)&Rexx_ReloadHook  },
  1646.       { "view"      ,""                    , 0        , (void *)&Rexx_ViewHook    },
  1647.       { "edit"      ,""                    , 0        , (void *)&Rexx_EditHook    },
  1648.       { NULL        , NULL                 , NULL     , NULL                      }
  1649.    };
  1650.  
  1651.    DB("\n*** moreHTML ***\n");
  1652.  
  1653.    filename[0] = 0;
  1654.  
  1655.    // Starting from CLI
  1656.    if(argc!=0)
  1657.    {
  1658.       HandleArgs(filename);
  1659.    }
  1660.    // Starting from WB
  1661.    else
  1662.    {
  1663.       wbmsg = (struct WBStartup *)argv;
  1664.  
  1665.       if(wbmsg->sm_NumArgs>=2)
  1666.       {
  1667.          NameFromLock(wbmsg->sm_ArgList[1].wa_Lock,filename,255);
  1668.          AddPart(filename,wbmsg->sm_ArgList[1].wa_Name,255);
  1669.       }
  1670.    }
  1671.  
  1672. // InitLocale();
  1673.  
  1674.    if (InitLibs())
  1675.    {
  1676.  
  1677.       if (InitClasses())
  1678.       {
  1679.  
  1680.          app = ApplicationObject,
  1681.             MUIA_Application_Title      , NAME,
  1682.             MUIA_Application_Version    , "$VER: " NAME" " VERS " " __AMIGADATE__,
  1683.             MUIA_Application_Copyright  , "Copyright © Dirk Holtwick, 1997",
  1684.             MUIA_Application_Author     , "Dirk Holtwick",
  1685.             MUIA_Application_Description, "Simple Offline HTML Browser based on HTMLtext.mcc",
  1686.             MUIA_Application_Base       , "MOREHTML",
  1687. //          MUIA_Application_SingleTask , TRUE,
  1688.             MUIA_Application_Commands   , commands,
  1689.             MUIA_Application_Window     , win  = NewObject(CL_MainWindow->mcc_Class,NULL,TAG_DONE),
  1690.             End;
  1691.  
  1692.          if (app)
  1693.          {
  1694.             // Get configuration
  1695.             DoMethod(win, MUIM_MainWindow_Config, TRUE);
  1696.  
  1697.             // Open window before a text is loaded,
  1698.             // otherwise the background is crippled
  1699.             set(win,MUIA_Window_Open,TRUE);
  1700.  
  1701.             if(filename[0]) DoMethod(win, MUIM_MainWindow_Open,filename);
  1702.  
  1703.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs)) != MUIV_Application_ReturnID_Quit)
  1704.             {
  1705.                if (sigs)
  1706.                {
  1707.                   sigs = Wait(sigs | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F);
  1708.  
  1709.                   /* quit when receiving break from console */
  1710.                   if (sigs & SIGBREAKF_CTRL_C)
  1711.                      break;
  1712.  
  1713.                   /* deiconify & activate on ctrl-f just like the other prefs programs */
  1714.                   if (sigs & SIGBREAKF_CTRL_F)
  1715.                   {
  1716.                      set(app,MUIA_Application_Iconified,FALSE);
  1717.                      set(win,MUIA_Window_Open,TRUE);
  1718.                   }
  1719.                }
  1720.             }
  1721.  
  1722.             // Remove temporary rexx file
  1723.             remove(TMPREXX);
  1724.             remove(TMPINFO);
  1725.  
  1726.             set(win,MUIA_Window_Open,FALSE);
  1727.          }
  1728.          MUI_DisposeObject(app);
  1729.          ExitClasses();
  1730.       }
  1731.       ExitLibs();
  1732.    }
  1733.  
  1734.    if (msg)
  1735.    {
  1736. /*
  1737.       char *str = GetStr(msg);
  1738.       char *c = strchr(str,'(');
  1739.       Write(Output(),str,strlen(str));
  1740.       res = c ? atol(c+1) : RETURN_OK;
  1741. */
  1742.       res = RETURN_OK;
  1743.    }
  1744.    else
  1745.       res = RETURN_OK;
  1746.  
  1747. //   ExitLocale();
  1748.  
  1749.    DB("*** finish ***\n");
  1750.  
  1751.    exit(res);
  1752. }
  1753. ///
  1754.  
  1755.